﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SM2DashBoard;

namespace SM2Panel
{
    public class Panel
    {
        public static void addPanel()
        {
            //Prepare data
            string strDBName = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("DashBoard Name");
            string stringChartName = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("Chart Name");
            string stringProfile = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("Profile Name");

            DashboardMainPage.selectDashboard(strDBName);
            System.Threading.Thread.Sleep(500);
            DashboardMainPage.clickAddPanels();
            System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_INTERVAL_MILISECOND);
            AddPanelsDialog.selectCharts(stringChartName);
            System.Threading.Thread.Sleep(500);
            AddPanelsDialog.selectProfile(stringProfile);
            System.Threading.Thread.Sleep(500);
            AddPanelsDialog.clickOK();
            DashboardMainPage.waitForAllPanelsLoaded();
        }

        public static void editPanel()
        {
            //Prepare data
            string strDBName = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("DashBoard Name");
            string strSelectedPanelName = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("Selected Panel Name");
            string strNewPanelName = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("New Panel Name");
            Boolean blCheckRestoreMaximize = SM2TestRunner.TestDispatcher.TEST_PARAMETER.get("Check Restore Maximize").ToLower().Equals("true")? true : false;

            DashboardMainPage.selectDashboard(strDBName);
            System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_INTERVAL_MILISECOND);

            int intPos = DashboardMainPage.findPositionPanel(strSelectedPanelName);
            System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_INTERVAL_MILISECOND);

            if (blCheckRestoreMaximize) DashboardMainPage.clickRestoreMaximize(intPos);
            System.Threading.Thread.Sleep(Utilities.GlobalConfig.INT_WAIT_INTERVAL_MILISECOND);

            DashboardMainPage.selectPanel(intPos, strSelectedPanelName);
            System.Threading.Thread.Sleep(500);

            EditPanelDialog.setName(intPos, strNewPanelName);
            System.Threading.Thread.Sleep(500);

            //EditPanelDialog.setChartType(intPos, strChartType);
            //EditPanelDialog.setProfile(intPos, strProfileName);
            //EditPanelDialog.setCategory(intPos, strCategory);

            EditPanelDialog.clickApply(intPos);
            DashboardMainPage.waitForAllPanelsLoaded();
        }
    }
}
